package com.llkj.qingnianguoxue.adapter;

import android.content.Context;
import android.view.View;
import android.widget.ImageView;

import com.bigkoo.convenientbanner.holder.Holder;
import com.llkj.qingnianguoxue.bean.LunboBean;
import com.llkj.qingnianguoxue.util.ImageLoadingUtil;

/**
 * 轮播图适配器
 */
public class CourseTeacherBannerAdapter implements Holder<LunboBean> {
    private ImageView imageView;
    private ClickBannerListener bannerListener;

    public CourseTeacherBannerAdapter(ClickBannerListener bannerListener) {
        this.bannerListener = bannerListener;
    }

    @Override
    public View createView(Context context) {
        imageView = new ImageView(context);

        return imageView;
    }

    @Override
    public void UpdateUI(final Context context, final int position, LunboBean data) {
        ImageLoadingUtil.loadingUrlCenterCrop(imageView, data.getImg());

        imageView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (bannerListener != null) {
                    bannerListener.clickBanner(position);
                }
            }
        });
    }

    public interface ClickBannerListener {
        void clickBanner(int position);
    }
}
